<template>
	<view class="container p_24 plr_24 pbsafe_56">
		<view  style="background: #FFEEE9; color:#FE5A1C; height: 72rpx; line-height: 72rpx; text-align: center;">
			收款：<text class="fc_zhured">￥{{price}}</text>
		</view>
		<view class="mt_60 fx jcc">
			<view class="width_300">
				<u-swiper :list="list" :indicator="true" height="766rpx" :autoplay="false" indicator
					:indicatorStyle="{'text-align': 'center', 'bottom': '48rpx'}" @click="handleClick">
				</u-swiper>
			</view>
		</view>
		<button class="custom_btn primary lh_40 w100 fz_14 br_27 mt_32" @click="handleReceive">确认收款</button>
	</view>
</template>

<script>
	import Image from '@/components/Image.vue'
	import api from '@/service/config/api.js'
	export default {
		components: {
			Image
		},
		props: {},
		data() {
			return {
				id: '',
				type: 1,
				dataInfo: {},
			};
		},
		onLoad(options) {
			this.id = options.id || ''
			this.type = options.type || 1
			this.getData()
		},
		computed: {
			price() {
				if (this.dataInfo.orderStatus == 6 && this.dataInfo.payType == 2) {
					return this.dataInfo.paidDeposit || 0
				}
				if (this.dataInfo.orderStatus == 9 && this.dataInfo.payType == 2) {
					return this.dataInfo.paidFinal || 0
				}
				return this.dataInfo.actualAmount || 0
			},
			list() {
				return (this.dataInfo.finalPayCertificate && this.dataInfo.finalPayCertificate.length > 0) ? this.dataInfo
					.finalPayCertificate : this.dataInfo
					.payCertificate
			}
		},
		methods: {
			getData() {
				this.$utils.loading()
				api.get(((this.orderType == 2 ? '/order/api/order/detailGzt/' : '/order/api/order/detail/')) + this.id)
					.then(res => {
						res.data.payCertificate = res.data.payCertificate ? res.data.payCertificate.split(',') : []
						res.data.finalPayCertificate = res.data.finalPayCertificate ? res.data.finalPayCertificate
							.split(',') : []
						res.data.orderStatus = this.$utils.orderSysStatus2status(res.data.sysOrderStatus) || res
							.data.orderStatus
						this.dataInfo = res.data
					})
			},
			handleClick(index) {
				uni.previewImage({
					urls: this.list,
					current: index
				})
			},
			handleReceive() {
				this.$utils.showModal({
					content: '确认收款吗？'
				}).then(() => {
					this.$utils.loading()
					api.get('/order/api/order/confirmReceivedPayment', {
						orderId: this.id
					}).then(res => {
						this.$utils.showToast('确认收款成功', 1500, 1, '', 'success')
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
</style>